package com.senior.sendmessage.config;

import cn.hutool.core.exceptions.ExceptionUtil;
import com.senior.sendmessage.common.ResultResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理配置
 * @author baijiliang
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    public ResultResponse exceptionCaught(Exception e) {
        log.info(e.getMessage());
        return ResultResponse.fail(ExceptionUtil.getSimpleMessage(e));
    }
}
